<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <form class="row form-inline m-t-5 text-right m-b-5" method="get" action="{:url('order/reserve')}">
        <input type="hidden" name="container_id" value="{$id}">
        <input type="hidden" name="reserve_type" value="{$Request.param.reserve_type}">
        <div class="col-6 text-left">进港时间段:</div><div class="col-6"><input type="submit" class="btn btn-primary" value="刷新" /></div>
    </form>
    <table class="table table-hover table-bordered">
        <tbody class="list-container">
        <foreach name="list" item="vo">
            <tr class="list-item">
                <td><a class="btn time-option" data-time="{$vo}" href="javascript:void(0);">{$vo}</td>
            </tr>
        </foreach>
        </tbody>
        <tfoot>
        <tr>
            <td></td>
        </tr>
        </tfoot>
    </table>
</div>
<div class="fixed-foot">
    <eq name="reserve_type" value="1">
        <div class="checkbox">
            <label>
                <input type="checkbox" class="specify_container_no" name="specify_container_no" value="1">指定箱号
            </label>
        </div>
    </eq>
    <button type="button" class="accept btn btn-primary w-120">确定</button>
</div>
<script src="__STATIC__/js/api.js"></script>
<style>
    tr {
        cursor: pointer;
    }
    .fixed-foot {
        border-top: 1px solid #d7d7d7;
        position: fixed;
        bottom: 0;
        width: 100%;
        text-align: center;
        background: #fff;
        padding: 10px;
        z-index: 99999;
    }
</style>
<script>
    $('.time-option').click(function () {
        $('.time-option').removeClass('btn-danger');
        $(this).addClass('btn-danger');
    });
    $('.accept').click(function () {
        var timeRangeChecked = $('.time-option.btn-danger');
        var specifyContainerNo = $('.specify_container_no').length > 0 && $('.specify_container_no').prop('checked') ? 1 : 0;
        console.log(timeRangeChecked);
        if(timeRangeChecked.length === 0) {
            layer.msg('请选择进港时段');
            return;
        }

        var timeRange = timeRangeChecked.data('time');
        $.post('{:url("order/reserveAcceptViaScan", ["id" => $id, "user_id" => $user_id, "car_no" => $car_no])}', {
            time_range: timeRange,
            specify_container_no: specifyContainerNo
        }, function (result) {
//            window.parent.window.location.reload();
            //回调关闭android端页面的方法
            // 由于对象映射，所以调用closeUtils对象等于调用Android映射的对象
            closeUtils.closeActivity(result);
        });
    });
</script>
</body>
</html>